
package ch.hearc.coursJava.examen.controle;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Image;
import java.rmi.RemoteException;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.WindowConstants;

import ch.hearc.coursJava.examen.dessin.Dessin_I;
import ch.hearc.coursJava.examen.dessin.JFrameDessin;

import com.bilat.tools.reseau.rmi.RmiTools;

/**
 *
 * @author raphael.capocasa
 *
 */
public class JFrameControle extends JFrame
	{
	/**
     * 
     */
    private static final long serialVersionUID = 865529888304862472L;
    /*------------------------------------------------------------------*\
	|*							Constructeurs							*|
	\*------------------------------------------------------------------*/
	public JFrameControle()
		{
		this.panelDessin = (Dessin_I)RmiTools.connectionRemoteObjectBloquant(RmiTools.getLocalHost().toString(), JFrameDessin.ID, RmiTools.getPortDefaultRMI());
		this.setLocation(0, 0);
		this.setTitle("Controle");
		this.setMinimumSize(new Dimension(140, 75));
		this.setMaximumSize(new Dimension(140, 75));
		ImageIcon imageIcon= new ImageIcon("./img/rose.png");
		this.image = imageIcon.getImage();
		this.setIconImage(image);

		creerPanels();
		placerPanels();

		this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
		this.setVisible(true); //Par d�faut: NON-visible, A mettre en dernier
		}

	/*------------------------------------------------------------------*\
	|*							Methodes Public							*|
	\*------------------------------------------------------------------*/

	/*------------------------------*\
	|*				Get				*|
	\*------------------------------*/
	public Thread getThread()
		{
		try
			{
			return this.panelDessin.giveThread().getThread();
			}
		catch (RemoteException e)
			{

			e.printStackTrace();
			return null;
			}
		}

	/*------------------------------------------------------------------*\
	|*							Methodes Private						*|
	\*------------------------------------------------------------------*/
	private void placerPanels()
		{
		BorderLayout layout = new BorderLayout();
		setLayout(layout);
		add(panelCentre, BorderLayout.CENTER);
		}

	private void creerPanels()
		{
		this.panelCentre = new JPanelCentre(this);
		}


	/*------------------------------------------------------------------*\
	|*							Attributs Private						*|
	\*------------------------------------------------------------------*/
	//tools
	private JPanelCentre panelCentre;
	private Image image;
	private Dessin_I panelDessin;

	}

